package cn.lds.j367.dsbank.service.impl;

import cn.lds.j367.dsbank.common.dto.ResultDTO;
import cn.lds.j367.dsbank.entity.Syslog;
import cn.lds.j367.dsbank.mapper.SyslogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class SyslogServiceImpl implements SyslogService{


    @Autowired
    private SyslogMapper syslogMapper;

    @Override
    public ResultDTO<List<Syslog>> selectLogAll() {

        List<Syslog> syslogs = syslogMapper.selectLogAll();

        if (CollectionUtils.isEmpty(syslogs)){
            return ResultDTO.buildError();
        }


        return ResultDTO.buildSuccess(syslogs);
    }

    @Override
    public ResultDTO addSyslog(Syslog syslog) {

        int i = syslogMapper.addSyslog(syslog);

        if (i<=0){
            return ResultDTO.buildError();
        }

        return ResultDTO.buildSuccess();
    }
}
